home *** CD-ROM | disk | FTP | other *** search
/ Family Fun / Family Fun.iso / joke1 / jokes_p / program.tao < prev    next >
Text File  |  1992-01-07  |  22KB  |  597 lines

  1.  
  2.  
  3.         The Tao Of Programming
  4.  
  5.         Translated By Geoffrey James
  6.         Transcribed By Seth Robertson
  7.  
  8.  
  9.         Table of Contents
  10.  
  11.             Book 1  --  The Silent Void
  12.             Book 2  --  The Ancient Masters
  13.             Book 3  --  Design
  14.             Book 4  --  Coding
  15.             Book 5  --  Maintenance
  16.             Book 6  --  Management
  17.             Book 7  --  Corporate Wisdom
  18.             Book 8  --  Hardware and Software
  19.             Book 9  --  Epilogue
  20.  
  21.  
  22.         The Silent Void
  23.         Book One
  24.  
  25.            Thus spake the master programmer:
  26.                    
  27.      "When you have learned to snatch the error code from
  28.       the trap frame, it will be time for you to leave."
  29.  
  30.                  1.1
  31.  
  32. Something mysterious is formed, born in the silent void.  Waiting alone
  33. and unmoving, it is at once still and yet in constant motion.  It is
  34. the source of all programs.  I do not know its name, so I will call it
  35. the Tao of Programming.
  36.  
  37. If the Tao is great, then the operating system is great.  If the
  38. operating system is great, then the compiler is great.  If the compiler
  39. is greater, then the applications is great.  The user is pleased and
  40. there is harmony in the world.
  41.  
  42. The Tao of Programming flows far away and returns on the wind of morning.
  43.  
  44.                   1.2
  45.  
  46. The Tao gave birth to machine language.  Machine language gave birth to
  47. the assembler.
  48.  
  49. The assembler gave birth to the compiler.  Now there are ten thousand
  50. languages.
  51.  
  52. Each language has its purpose, however humble.  Each language expresses
  53. the Yin and Yang of software.  Each language has its place within the Tao.
  54.  
  55. But do not program in COBOL if you can avoid it.
  56.  
  57.                   1.3
  58.  
  59. In the beginning was the Tao.  The Tao gave birth to Space and Time.
  60. Therefore, Space and Time are the Yin and Yang of programming.
  61.  
  62. Programmers that do not comprehend the Tao are always running out of
  63. time and space for their programs.  Programmers that comprehend the Tao
  64. always have enough time and space to accomplish their goals.
  65.  
  66. How could it be otherwise?
  67.  
  68.                   1.4
  69.  
  70. The wise programmer is told about the Tao and follows it.  The average
  71. programmer is told about the Tao and searches for it.  The foolish
  72. programmer is told about the Tao and laughs at it.
  73.  
  74. If it were not for laughter, there would be no Tao.
  75.  
  76. The highest sounds are the hardest to hear.  Going forward is a way to
  77. retreat.  Greater talent shows itself late in life.  Even a perfect
  78. program still has bugs.
  79.  
  80.             The Ancient Masters
  81.                 Book Two
  82.  
  83.            Thus spake the master programmer:
  84.                    
  85.    "After three days without programming, life becomes meaningless."
  86.  
  87.                   2.1
  88.  
  89. The programmers of old were mysterious and profound.  We cannot fathom
  90. their thoughts, so all we do is describe their appearance.
  91.  
  92. Aware, like a fox crossing the water.  Alert, like a general on the
  93. battlefield.  Kind, like a hostess greeting her guests. Simple, like
  94. uncarved blocks of wood.  Opaque, like black pools in darkened caves.
  95.  
  96. Who can tell the secrets of their hearts and minds?
  97.  
  98. The answer exists only in the Tao.
  99.  
  100.                   2.2
  101.  
  102. Grand Master Turing once dreamed that he was a machine.  When he awoke
  103. he exclaimed:
  104.  
  105.      "I don't know whether I am Turing dreaming that I am a machine,
  106.       or a machine dreaming that I am Turing!"
  107.  
  108.                   2.3
  109.  
  110. A programmer from a very large computer company went to a software
  111. conference and then returned to report to his manager, saying: "What
  112. sort of programmers work for other companies?  They behaved badly and
  113. were unconcerned with appearances. Their hair was long and unkempt and
  114. their clothes were wrinkled and old. They crashed out hospitality
  115. suites and they made rude noises during my presentation."
  116.  
  117. The manager said: "I should have never sent you to the conference.
  118. Those programmers live beyond the physical world.  They consider life
  119. absurd, an accidental coincidence.  They come and go without knowing
  120. limitations.  Without a care, they live only for their programs.  Why
  121. should they bother with social conventions?"
  122.  
  123. "They are alive within the Tao."
  124.  
  125.                   2.4
  126.  
  127. A novice asked the Master: "Here is a programmer that never designs,
  128. documents, or tests his programs.  Yet all who know him consider him
  129. one of the best programmers in the world.  Why is this?"
  130.  
  131. The Master replies: "That programmer has mastered the Tao.  He has gone
  132. beyond the need for design; he does not become angry when the system
  133. crashes, but accepts the universe without concern.  He has gone beyond
  134. the need for documentation; he no longer cares if anyone else sees
  135. his code.  He has gone beyond the need for testing; each of his
  136. programs are perfect within themselves, serene and elegant, their
  137. purpose self-evident.  Truly, he has entered the mystery of the Tao."
  138.  
  139.                 Design
  140.                 Book Three
  141.  
  142.            Thus spake the master programmer:
  143.                    
  144. "When program is being tested, it is too late to make design changes."
  145.  
  146.                   3.1
  147.  
  148. There once was a man who went to a computer trade show.  Each day as he
  149. entered, the man told the guard at the door:
  150.  
  151.      "I am a great thief, renowned for my feats of shoplifting.  Be
  152.       forewarned, for this trade show shall not escape unplundered."
  153.  
  154. This speech disturbed the guard greatly, because there were millions of
  155. dollars of computer equipment inside, so he watched the man carefully.
  156. But the man merely wandered from booth to booth, humming quietly to
  157. himself.
  158.  
  159. When the man left, the guard took him aside and searched his clothes,
  160. but nothing was to be found.
  161.  
  162. On the next day of the trade show, the man returned and chided the
  163. guard saying: "I escaped with a vast booty yesterday, but today will be
  164. even better."  So the guard watched him ever more closely, but to no
  165. avail.
  166.  
  167. On the final day of the trade show, the guard could restrain his
  168. curiosity no longer. "Sir Thief," he said, "I am so perplexed, I cannot
  169. live in peace.  Please enlighten me.  What is it that you are stealing?"
  170.  
  171. The man smiled.  "I am stealing ideas," he said.
  172.  
  173.                   3.2
  174.  
  175. There once was a master programmer who wrote unstructured programs.  A
  176. novice programmer, seeking to imitate him, also began to write
  177. unstructured programs.  When the novice asked the master to evaluate
  178. his progress, the master criticized him for writing unstructured
  179. programs, saying: "What is appropriate for the master is not
  180. appropriate for the novice.  You must understand the Tao before
  181. transcending structure."
  182.  
  183.                   3.3
  184.  
  185. There was once a programmer who was attached to the court of the
  186. warlord of Wu.  The warlord asked the programmer: "Which is easier to
  187. design: an accounting package or an operating system?"
  188.  
  189. "An operating system," replied the programmer.
  190.  
  191. The warlord uttered an exclamation of disbelief.  "Surely an accounting
  192. package is trivial next to the complexity of an operating system," he said.
  193.  
  194. "Not so," said the programmer, "when designing an accounting package,
  195. the programmer operates as a mediator between people having different
  196. ideas: how it must operate, how its reports must appear, and how it
  197. must conform to the tax laws.  By contrast, an operating system is not
  198. limited my outside appearances.  When designing an operating system,
  199. the programmer seeks the simplest harmony between machine and ideas.
  200. This is why an operating system is easier to design."
  201.  
  202. The warlord of Wu nodded and smiled.  "That is all good and well, but
  203. which is easier to debug?"
  204.  
  205. The programmer made no reply.
  206.  
  207.                   3.4
  208.  
  209. A manager went to the master programmer and showed him the requirements
  210. document for a new application.  The manager asked the master: "How
  211. long will it take to design this system if I assign five programmers
  212. to it?"
  213.  
  214. "It will take one year," said the master promptly.
  215.  
  216. "But we need this system immediately or even sooner!  How long will it
  217. take it I assign ten programmers to it?"
  218.  
  219. The master programmer frowned.  "In that case, it will take two years."
  220.  
  221. "And what if I assign a hundred programmers to it?"
  222.  
  223. The master programmer shrugged.  "Then the design will never be
  224. completed," he said.
  225.  
  226.                 Coding
  227.                 Book Four
  228.  
  229.            Thus spake the master programmer:
  230.                    
  231.           "A well-written program is its own heaven;
  232.           a poorly-written program is its own hell."
  233.  
  234.                   4.1
  235.  
  236. A program should be light and agile, its subroutines connected like a
  237. strings of pearls.  The spirit and intent of the program should be
  238. retained throughout.  There should be neither too little nor too much,
  239. neither needless loops nor useless variables, neither lack of structure
  240. nor overwhelming rigidity.
  241.  
  242. A program should follow the 'Law of Least Astonishment'.  What is this
  243. law?  It is simply that the program should always respond to the user
  244. in the way that astonishes him least.
  245.  
  246. A program, no matter how complex, should act as a single unit.  The
  247. program should be directed by the logic within rather than by outward
  248. appearances.
  249.  
  250. If the program fails in these requirements, it will be in a state of
  251. disorder and confusion.  The only way to correct this is to rewrite the
  252. program.
  253.  
  254.                   4.2
  255.  
  256. A novice asked the master: "I have a program that sometimes runs and
  257. sometimes aborts.  I have followed the rules of programming, yet I am
  258. totally baffled. What is the reason for this?"
  259.  
  260. The master replied: "You are confused because you do not understand the
  261. Tao.  Only a fool expects rational behavior from his fellow humans. Why
  262. do you expect it from a machine that humans have constructed? Computers
  263. simulate determinism; only the Tao is perfect.
  264.  
  265. The rules of programming are transitory; only the Tao is eternal.
  266. Therefore you must contemplate the Tao before you receive enlightenment."
  267.  
  268. "But how will I know when I have received enlightenment?" asked the novice.
  269.  
  270. "Your program will then run correctly," replied the master.
  271.  
  272.                   4.3
  273.  
  274. A master was explaining the nature of the Tao to one of his novices,
  275. "The Tao is embodied in all software -- regardless of how
  276. insignificant," said the master.
  277.  
  278. "Is the Tao in a hand-held calculator?" asked the novice.
  279.  
  280. "It is," came the reply.
  281.  
  282. "Is the Tao in a video game?" continued the novice.
  283.  
  284. "It is even in a video game," said the master.
  285.  
  286. "And is the Tao in the DOS for a personal computer?"
  287.  
  288. The master coughed and shifted his position slightly.  "The lesson is
  289. over for today," he said.
  290.  
  291.                   4.4
  292.  
  293. Price Wang's programmer was coding software.  His fingers danced upon
  294. the keyboard.  The program compiled without an error message, and the
  295. program ran like a gentle wind.
  296.  
  297. Excellent!" the Price exclaimed, "Your technique is faultless!"
  298.  
  299. "Technique?" said the programmer, turning from his terminal, "What I
  300. follow is the Tao -- beyond all technique.  When I first began to
  301. program I would see before me the whole program in one mass.  After
  302. three years I no longer saw this mass. Instead, I used subroutines.
  303. But now I see nothing.  My whole being exists in a formless void.  My
  304. senses are idle.  My spirit, free to work without a plan, follows its
  305. own instinct.  In short, my program writes itself. True, sometimes
  306. there are difficult problems.  I see them coming, I slow down, I watch
  307. silently. Then I change a single line of code and the difficulties
  308. vanish like puffs of idle smoke.  I then compile the program.  I sit
  309. still and let the joy of the work fill my being.  I close my eyes for a
  310. moment and then log off."
  311.  
  312. Price Wang said, "Would that all of my programmers were as wise!"
  313.  
  314.             Maintenance
  315.             Book Five
  316.  
  317.            Thus spake the master programmer:
  318.                    
  319.           "Though a program be but three lines long,
  320.            someday it will have to be maintained."
  321.  
  322.                   5.1
  323.  
  324.        A well-used door needs no oil on its hinges.
  325.        A swift-flowing steam does no grow stagnant.
  326.        Neither sound nor thoughts can travel through a vacuum.
  327.        Software rots if not used.
  328.  
  329.        These are great mysteries.
  330.  
  331.                   5.2
  332.  
  333. A manager asked a programmer how long it would take him to finish the
  334. program on which he was working.  "I will be finished tomorrow," the
  335. programmer promptly replied.
  336.  
  337. "I think you are being unrealistic," said the manager. "Truthfully, how
  338. long will it take?"
  339.  
  340. The programmer thought for a moment.  "I have some features that I wish
  341. to add.  This will take at least two weeks," he finally said.
  342.  
  343. "Even that is too much to expect," insisted the manager, "I will be
  344. satisfied if you simply tell me when the program is complete."
  345.  
  346. The programmer agreed to this.
  347.  
  348. Several years slated, the manager retired.  On the way to his
  349. retirement lunch, he discovered the programmer asleep at his terminal.
  350. He had been programming all night.
  351.  
  352.                   5.3
  353.  
  354. A novice programmer was once assigned to code a simple financial
  355. package.
  356.  
  357. The novice worked furiously for many days, but when his master reviewed
  358. his program, he discovered that it contained a screen editor, a set of
  359. generalized graphics routines, and artificial intelligence interface,
  360. but not the slightest mention of anything financial.
  361.  
  362. When the master asked about this, the novice became indignant.  "Don't
  363. be so impatient," he said, "I'll put the financial stuff in eventually."
  364.  
  365.                   5.4
  366.  
  367.       Does a good farmer neglect a crop he has planted?
  368.       Does a good teacher overlook even the most humble student?
  369.       Does a good father allow a single child to starve?
  370.       Does a good programmer refuse to maintain his code?
  371.  
  372.                 Management
  373.                 Book Six
  374.  
  375.            Thus spake the master programmer:
  376.                    
  377.          "Let the programmer be many and the managers
  378.          few -- then all will be productive."
  379.  
  380.                   6.1
  381.  
  382. When managers hold endless meetings, the programmers write games.  When
  383. accountants talk of quarterly profits, the development budget is about
  384. to be cut.  When senior scientists talk blue sky, the clouds are about
  385. to roll in.
  386.  
  387. Truly, this is not the Tao of Programming.
  388.  
  389. When managers make commitments, game programs are ignored.  When
  390. accountants make long-range plans, harmony and order are about to be
  391. restored.  When senior scientists address the problems at hand, the
  392. problems will soon be solved.
  393.  
  394. Truly, this is the Tao of Programming.
  395.  
  396.                   6.2
  397.  
  398. Why are programmers non-productive?
  399. Because their time is wasted in meetings.
  400.  
  401. Why are programmers rebellious?
  402. Because the management interferes too much.
  403.  
  404. Why are the programmers resigning one by one?
  405. Because they are burnt out.
  406.  
  407. Having worked for poor management, they no longer value their jobs.
  408.  
  409.                   6.3
  410.  
  411. A manager was about to be fired, but a programmer who worked for him
  412. invented a new program that became popular and sold well.  As a result,
  413. the manager retained his job.
  414.  
  415. The manager tried to give the programmer a bonus, but the programmer
  416. refused it, saying, "I wrote the program because I though it was an
  417. interesting concept, and thus I expect no reward."
  418.  
  419. The manager, upon hearing this, remarked, "This programmer, though he
  420. holds a position of small esteem, understands well the proper duty of
  421. an employee.  Lets promote him to the exalted position of management
  422. consultant!"
  423.  
  424. But when told this, the programmer once more refused, saying, "I exist
  425. so that I can program.  If I were promoted, I would do nothing but
  426. waste everyone's time.  Can I go now?  I have a program that I'm
  427. working one."
  428.  
  429.                   6.4
  430.  
  431. A manger went to his programmers and told them: "As regards to your
  432. work hours: you are going to have to come in at nine in the morning and
  433. leave at five in the afternoon."  At this, all of them became angry and
  434. several resigned on the spot.
  435.  
  436. So the manager said: "All right, in that case you may set your own
  437. working hours, as long as you finish your projects on schedule."  The
  438. programmers, now satisfied, began to come in a noon and work to the wee
  439. hours of the morning.
  440.  
  441.             Corporate Wisdom
  442.             Book Seven
  443.  
  444.            Thus spake the master programmer:
  445.                    
  446.         "You can demonstrate a program for a corporate
  447.     executive, but you can't make him computer literate."
  448.  
  449.                   7.1
  450.  
  451. A novice asked the master: "In the east there is a great tree-structure
  452. that men call 'Corporate Headquarters'.  It is bloated out of shape
  453. with vice-presidents and accountants.  It issues a multitude of memos,
  454. each saying 'Go, Hence!' or 'Go, Hither!' and nobody knows what is
  455. meant.  Every year new names are put onto the branches, but all to no
  456. avail.  How can such an unnatural entity exist?"
  457.  
  458. The master replies: "You perceive this immense structure and are
  459. disturbed that it has no rational purpose.  Can you not take amusement
  460. from its endless gyrations?  Do you not enjoy the untroubled ease of
  461. programming beneath its sheltering branches?  Why are you bothered by
  462. its uselessness?"
  463.  
  464.                   7.2
  465.  
  466. In the east there is a shark which is larger than all other fish.  It
  467. changes into a bird whose winds are like clouds filling the sky.  When
  468. this bird moves across the land, it brings a message from Corporate
  469. Headquarters.  This message it drops into the midst of the program-
  470. mers, like a seagull making its mark upon the beach.  Then the bird
  471. mounts on the wind and, with the blue sky at its back, returns home.
  472.  
  473. The novice programmer stares in wonder at the bird, for he understands
  474. it not.  The average programmer dreads the coming of the bird, for he
  475. fears its message.  The master programmer continues to work at his
  476. terminal, for he does not know that the bird has come and gone.
  477.  
  478.                   7.3
  479.  
  480. The Magician of the Ivory Tower brought his latest invention for the
  481. master programmer to examine.  The magician wheeled a large black box
  482. into the master's office while the master waited in silence.
  483.  
  484. "This is an integrated, distributed, general-purpose workstation,"
  485. began the magician, "ergonomically designed with a proprietary
  486. operating system, sixth generation languages, and multiple state of the
  487. art user interfaces.  It took my assistants several hundred man years
  488. to construct.  Is it not amazing?"
  489.  
  490. The master raised his eyebrows slightly. "It is indeed amazing," he
  491. said.
  492.  
  493. "Corporate Headquarters has commanded," continued the magician, "that
  494. everyone use this workstation as a platform for new programs.  Do you
  495. agree to this?"
  496.  
  497. "Certainly," replied the master, "I will have it transported to the
  498. data center immediately!"  And the magician returned to his tower, well
  499. pleased.
  500.  
  501. Several days later, a novice wandered into the office of the master
  502. programmer and said, "I cannot find the listing for my new program.  Do
  503. you know where it might be?"
  504.  
  505. "Yes," replied the master, "the listings are stacked on the platform in
  506. the data center."
  507.  
  508.                   7.4
  509.  
  510. The master programmer moves from program to program without fear.  No
  511. change in management can harm him.  He will not be fired, even if the
  512. project is canceled. Why is this?  He is filled with the Tao.
  513.  
  514.             Hardware and Software
  515.             Book Eight
  516.  
  517.            Thus spake the master programmer:
  518.                    
  519.          "Without the wind, the grass does not move.
  520.            Without software, hardware is useless."
  521.  
  522.                   8.1
  523.  
  524. A novice asked the master: "I perceive that one computer company is
  525. much larger than all others.  It towers above its competition like a
  526. giant among dwarfs.  Any one of its divisions could comprise an entire
  527. business.  Why is this so?"
  528.  
  529. The master replied, "Why do you ask such foolish questions?  That
  530. company is large because it is so large.  If it only made hardware,
  531. nobody would buy it.  If it only maintained systems, people would treat
  532. it like a servant.  But because it combines all of these things, people
  533. think it one of the gods!  By not seeking to strive, it conquers
  534. without effort."
  535.  
  536.                   8.2
  537.  
  538. A master programmer passed a novice programmer one day.  The master
  539. noted the novice's preoccupation with a hand-held computer game.
  540. "Excuse me", he said, "may I examine it?"
  541.  
  542. The novice bolted to attention and handed the device to the master. "I
  543. see that the device claims to have three levels of play: Easy, Medium,
  544. and Hard", said the master.  "Yet every such device has another level
  545. of play, where the device seeks not to conquer the human, nor to be
  546. conquered by the human."
  547.  
  548. "Pray, great master," implored the novice, "how does one find this
  549. mysterious setting?"
  550.  
  551. The master dropped the device to the ground and crushed it under foot.
  552. And suddenly the novice was enlightened.
  553.  
  554.                   8.3
  555.  
  556. There was once a programmer who worked upon microprocessors.  "Look at
  557. how well off I am here," he said to a mainframe programmer who came to
  558. visit, "I have my own operating system and file storage device. I do
  559. not have to share my resources with anyone.  The software is
  560. self-consistent and easy-to-use.  Why do you not quit your present job
  561. and join me here?"
  562.  
  563. The mainframe programmer then began to describe his system to his
  564. friend, saying: "The mainframe sits like an ancient sage meditating in
  565. the midst of the data center.  Its disk drives lie end-to-end like a
  566. great ocean of machinery.  The software is a multi-faceted as a diamond
  567. and as convoluted as a primeval jungle.  The programs, each unique,
  568. move through the system like a swift-flowing river.  That is why I am
  569. happy where I am."
  570.  
  571. The microcomputer programmer, upon hearing this, fell silent.  But the
  572. two programmers remained friends until the end of their days.
  573.  
  574.                   8.4
  575.  
  576. Hardware met Software on the road to Changtse.  Software said: "You are
  577. the Yin and I am the Yang.  If we travel together we will become famous
  578. and earn vast sums of money."  And so the pair set forth together,
  579. thinking to conquer the world.
  580.  
  581. Presently, they met Firmware, who was dressed in tattered rags, and
  582. hobbled along propped on a thorny stick.  Firmware said to them: "The
  583. Tao lies beyond Yin and Yang.  It is silent and still as a pool of
  584. water. It does not seek fame, therefore nobody knows its presence.  It
  585. does not seeks fortune, for it is complete within itself.  It exists
  586. beyond space and time."
  587.  
  588. Software and Hardware, ashamed, returned to their homes.
  589.  
  590.  
  591.                 Epilogue
  592.                 Book Nine
  593.  
  594.            Thus spake the master programmer:
  595.                    
  596.                "Time for you to leave."
  597.